﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Alogient.Cameleon.Sdk;
using Alogient.Cameleon.Sdk.Items;

namespace Alogient.Cameleon.Sdk.tests
{
    [TestFixture]
    public class CMServicesTest : FixtureBase
    {
        [SetUp]
        public void Init()
        {
        }

        [TearDown]
        public void Finish()
        {
        }

        [Test]
        public void IsLive()
        {
            bool result = CMServices.IsLive;
            Assert.IsTrue(result);
        }

        [Test]
        public void GetCachedPage()
        {
            var navID = 1;
            var cultureCode = frCultureCode;
            var page = CMServices.GetCachedPage(navID, cultureCode);

            Assert.AreEqual(navID, page.NavID);
            Assert.AreEqual(cultureCode, page.CultureCode);
        }

        [Test]
        public void GetAllCultures()
        {
            var cultures = CMServices.GetAllCultures();

            Assert.AreEqual(2, cultures.Count());
        }

        [Test]
        public void PageExists1()
        {
            var navID = 0;
            var result = CMServices.PageExists(navID);
            Assert.IsTrue(result);
        }

        [Test]
        public void PageExists2()
        {
            var navID = this.navID;
            var cultureCode = "fr-CA";
            var result = CMServices.PageExists(navID, cultureCode);

            Assert.IsTrue(result);
        }

        [Test]
        public void PageExist3()
        {
            var result = CMServices.PageExists(-1);

            Assert.IsFalse(result);
        }

        [Test]
        public void GetPage1()
        {
            var page = CMServices.GetPage();
            Assert.AreEqual(CMSettings.DefaultNavID, page.NavID);
        }

        [Test]
        public void GetPage2()
        {
            var navID = 0;
            CMServices.GetPage(navID);
        }

        [Test]
        public void GetPage3()
        {
            var navID = 0;
            var cultureCode = frCultureCode;
            CMServices.GetPage(navID, cultureCode);
        }
        
        [Test]
        public void GetPagesByTemplate()
        {
            var templateName = basicTemplateName;
            var cultureCode = frCultureCode;
            var pages = CMServices.GetPagesByTemplate(templateName, cultureCode);

            Assert.GreaterOrEqual(1, pages.Count());
            Assert.AreEqual(templateName, pages[0].TemplateName);
            Assert.AreEqual(cultureCode, pages[0].CultureCode);
        }

        [Test]
        public void GetPagesByTemplate2()
        {
            var templateName = "this template doesnt exists";
            var cultureCode = frCultureCode;
            var pages = CMServices.GetPagesByTemplate(templateName, cultureCode);

            Assert.GreaterOrEqual(1, pages.Count());
        }

        [Test]
        public void XmlBreadcrumbs1()
        {
            var navID = 0;
            var xmlBreadcrumbs = CMServices.XmlBreadcrumbs(navID);

            // TODO Assert with xml
        }

        [Test]
        public void XmlBreadcrumbs2()
        {
            var navID = 0;
            var cultureCode = "fr-CA";
            var xmlBreadcrumbs = CMServices.XmlBreadcrumbs(navID, cultureCode);

            // TODO Assert with xml
        }

        [Test]
        public void GetVideo()
        {
            var videoID = this.navID;
            var cultureCode = frCultureCode;
            var video = CMServices.GetVideo(videoID, cultureCode);

            Assert.IsNull(video);
        }
    }
}
